import Vue from 'vue';
import VueRouter from 'vue-router';
import Reg from './pages/Reg.vue';
import Login from './pages/Login.vue';
import Manage from './pages/Manage.vue';
import Student from './pages/Student.vue';
import Class from './pages/Class.vue';
import Teacher from './pages/Teacher.vue';
import Test from './pages/Test.vue';
import Test1 from './pages/Test1.vue';
import TestVuex from './pages/TestVuex.vue';
Vue.use(VueRouter);

const routes = [
    { path: '/vuex', component: TestVuex },
    { path: '/test', component: Test },
    { path: '/test1', component: Test1 },
    { path: '/reg', component: Reg },
    { path: '/login', component: Login },
    { path: '/manage', component: Manage 
    ,children:[
        { path: 'student', component: Student },
        { path: 'class', component: Class },
        { path: 'teacher', component: Teacher }
    ]}
]

const router = new VueRouter({
    mode: 'history',
    routes // (缩写) 相当于 routes: routes
})

// router.beforeEach((to, from, next) => {
//     console.log("beforeEach",to,from);
//     if(to.fullPath != '/login'){
//         next('/login');
//     }else{
//         next();
//     }
    
// });

export default router;